Any regular expression, either simple or compound, followed by an asterisk, indicates that zero or more repetitions of the regular expression will be matched. For example,
[0-9][0-9]*
matches a pattern of characters starting with a digit, followed by zero or more additional digits. This is a typical example of a regular expression used to match a pattern of characters representing a typical number.
[A-Z][a-z]*
The regular expression above matches an uppercase letter followed by zero or more lowercase letters.
The '+' character can be used in a similar manner to '*' to match one or more repetitions of the preceding regular expression. For example,
[0-9]+
matches a sequence of one or more digits, which is the same as the previous example,
[0-9][0-9]*
Using the brace brackets you can specify a specific number or repetitions for a regular expression. For example,
[0-9]{3}
matches a sequence of three digits. A range of repetitions can be defined within the brace brackets. For example,
[0-9]{1,10}
matches a sequence of 1 to 10 digits.
See Also